import Vue from 'vue'
//时间戳转换年月日 时分秒
Vue.prototype.Convert = function(Unix) {			//精确到时分秒
  var Time = new Date(Unix*1000);
  var hours,minutes,seconds;
  parseInt(Time.getHours())<10? hours='0'+Time.getHours() : hours=Time.getHours();
  Time.getMinutes()<10? minutes='0'+Time.getMinutes() : minutes=Time.getMinutes();
  Time.getSeconds()<10? seconds='0'+Time.getSeconds() : seconds=Time.getSeconds();
  return(Time.getFullYear() + "-" + (Time.getMonth() + 1) + "-" + Time.getDate()+'  '+hours+':'+minutes+':'+seconds);
}
//时间戳转换年月日
Vue.prototype.Convert_year = function(Unix) {
  var Time = new Date(Unix);
  var hours,minutes,seconds;
  parseInt(Time.getHours())<10? hours='0'+Time.getHours() : hours=Time.getHours();
  Time.getMinutes()<10? minutes='0'+Time.getMinutes() : minutes=Time.getMinutes();
  Time.getSeconds()<10? seconds='0'+Time.getSeconds() : seconds=Time.getSeconds();
  return(Time.getFullYear() + "-" + (Time.getMonth() + 1) + "-" + Time.getDate());
}
Vue.prototype.GetDateStr = function(AddDayCount) {			//精确到时分秒
   var dd = new Date();
       dd.setDate(dd.getDate()+AddDayCount);//获取AddDayCount天后的日期
       var y = dd.getFullYear();
       var m = (dd.getMonth()+1)<10?"0"+(dd.getMonth()+1):(dd.getMonth()+1);//获取当前月份的日期，不足10补0
       var d = dd.getDate()<10?"0"+dd.getDate():dd.getDate();//获取当前几号，不足10补0
       //return y+"-"+m+"-"+d; 获取年月日
       return m+"-"+d;
}
Vue.prototype.imgPreview = function(file,index,callback){	//图片上传预览
		//fileArray接收图片回显变量 index=true是设置为字符串 index=false时设置为数组批量添加
		//file e.target.files[0]文件本地路径
		var self=this;
    // 看支持不支持FileReader
    if (!file || !window.FileReader) return;
    if (/^image/.test(file.type)) {
        // 创建一个reader
        var reader = new FileReader();
        // 将图片将转成 base64 格式
        reader.readAsDataURL(file);
        // 读取成功后的回调
        reader.onloadend = function () {
          callback && callback(this.result)
        	//index? self.fileArray=this.result : self.fileArray.unshift(this.result);
//      	index? self.$set(self.fileArray,0,this.result ) : self.fileArray.unshift(this.result);
        }
    }

}

Vue.prototype.toolbarOptions = function(){	// 富文本工具栏配置
		const toolbarOptions = [
		  ['bold', 'italic', 'underline', 'strike'],        // toggled buttons
		  ['blockquote', 'code-block'],

		  [{'header': 1}, {'header': 2}],               // custom button values
		  [{'list': 'ordered'}, {'list': 'bullet'}],
		  [{'script': 'sub'}, {'script': 'super'}],      // superscript/subscript
		  [{'indent': '-1'}, {'indent': '+1'}],          // outdent/indent
		  [{'direction': 'rtl'}],                         // text direction

		  [{'size': ['small', false, 'large', 'huge']}],  // custom dropdown
		  [{'header': [1, 2, 3, 4, 5, 6, false]}],

		  [{'color': []}, {'background': []}],          // dropdown with defaults from theme
		  [{'font': []}],
		  [{'align': []}],
		  ['link', 'image', 'video'],
		  ['clean']                                         // remove formatting button
		];
		return toolbarOptions;

}


export default Vue;
